import React from "react";
import { StrictMode } from "react";
import { createRoot } from "react-dom/client";
import App from "./App.jsx";
import {
  qiankunWindow,
  renderWithQiankun,
} from "vite-plugin-qiankun/dist/helper";
// createRoot(document.getElementById("root")).render(
//   <StrictMode>
//     <App />
//   </StrictMode>
// );
let root = null;
if (!qiankunWindow.__POWERED_BY_QIANKUN__) {
  render();
} else {
  renderWithQiankun({
    mount(props) {
      console.log("react应用挂载");
      console.log("react props", props);
      render(props);
    }, //props 配置中的内容

    bootstrap() {
      console.log("react应用初始化");
    },
    update() {
      console.log("react应用更新");
    },
    unmount() {
      console.log("react应用卸载");
      root.unmount();
    },
  });
}
function render(props) {
  const { container } = props;
  const dom = container
    ? container.querySelector("#root")
    : document.getElementById("root");
  root = createRoot(dom);
  root.render(<App />);
}
